//
//  OneInVcDetailHeaderView.m
//  Runone
//
//  Created by runone02 on 16/10/25.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "OneInVcDetailHeaderView.h"
#import <MAMapKit/MAMapKit.h>
#import <AMapFoundationKit/AMapFoundationKit.h>
#import "Masonry.h"
#import "Define.h"
#import "AppConstants.h"
#import "CustomAnnotationView.h"
#import "CustomCallOutView.h"
#import "ROPointAnnotation.h"
#import "RightCodeTool.h"
#import "OneConst.h"

@interface OneInVcDetailHeaderView () <MAMapViewDelegate>

// ******************************* - 地图 - *******************************
@property (nonatomic, strong) UIView *mapBackView;
@property (nonatomic, strong) MAMapView *mapView;

// ******************************* - 用车信息 - *******************************
@property (nonatomic, strong) UILabel *carMessageL; //用车信息
@property (nonatomic, strong) UILabel *driverL;     //司机
@property (nonatomic, strong) UILabel *speedL;      //车速
@property (nonatomic, strong) UILabel *userNameL;    //用车人
@property (nonatomic, strong) UILabel *departureL;  //出发地
@property (nonatomic, strong) UILabel *destinationL;//目的地
@property (nonatomic, strong) UILabel *returnTimeL; //返程时间

// ******************************* - 历史轨迹查询 - *******************************
@property (nonatomic, strong) UILabel *trackL;    // 历史轨迹查询
//@property (nonatomic, strong) UIView *trackBackV; //历史轨迹的containner
// ******************************* - 车载视频截图 - *******************************
@property (nonatomic, strong) UILabel *videoL; //车载视频截图
// ******************************* - 地图标注数组 - *******************************
@property (nonatomic, strong) NSMutableArray *annotationsArray;

@property (nonatomic, assign) AllIconType type;
@end

@implementation OneInVcDetailHeaderView


#pragma     -------查询车辆信息界面


- (void) trafficBtnClick:(UIButton *)btn {
    btn.selected = !btn.selected;
    if (btn.selected) {
        _mapView.showTraffic=YES;
    } else {
        _mapView.showTraffic=NO;
    }
}

- (instancetype)initWithFrame:(CGRect)frame {
    if ([super initWithFrame:frame]) {
        _annotationsArray = [[NSMutableArray alloc]init];
        self.backgroundColor = [UIColor whiteColor];
        [self configUI];
        [self layoutUI];
        
    }
    return self;
}

//- (void)setVcType:(NSInteger)vcType {
//    _vcType = vcType;
//}

//    if (_vcType == 1 && [[RightCodeTool sharedTool] rightIsEqualTO:@"P030103"]) {
//        _trackBackV.hidden = YES;
//    }
//    if (_vcType == 2 && [[RightCodeTool sharedTool] rightIsEqualTO:@"P030302"]) {
//        _trackBackV.hidden = YES;
//    }
//    if (_vcType == 2 && [[RightCodeTool sharedTool] rightIsEqualTO:@"P030402e"]) {
//        _trackBackV.hidden = YES;
//    }
//    _trackBackV.hidden = YES;

- (void) configUI {
    // 地图
    _mapBackView = [[UIView alloc] init];
    [self addSubview:_mapBackView];
    
    [AMapServices sharedServices].apiKey = GETGAODEPAIKEY;
    _mapView              = [[MAMapView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 200)];
    _mapView.delegate     = self;
    _mapView.showsCompass = NO;
    _mapView.showsScale   = NO;
    [_mapBackView addSubview:_mapView];
    
    _enlargeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_enlargeBtn setBackgroundImage:[UIImage imageNamed:@"map_enlarge"] forState:UIControlStateNormal];
    [_mapBackView addSubview:_enlargeBtn];
    
    _trafficBtn                 = [UIButton buttonWithType:UIButtonTypeCustom];
    _trafficBtn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
    [_trafficBtn setBackgroundImage:[UIImage imageNamed:@"traffic_light"] forState:UIControlStateNormal];
    [_trafficBtn setBackgroundImage:[UIImage imageNamed:@"traffic_light_selected"] forState:UIControlStateSelected];
    [_trafficBtn addTarget:self action:@selector(trafficBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [_mapBackView addSubview:_trafficBtn];
    
    //用车信息
    _carMessageL = [[UILabel alloc] init];
    _carMessageL.font = [UIFont fontWithName:@"HelveticaNeue" size:17];
    _carMessageL.text      = @"   用车信息";
    
    [self addSubview:_carMessageL];
    
    _driverL = [[UILabel alloc] init];
    _driverL.font      = [UIFont systemFontOfSize:15];
    _driverL.textColor = kROLightFrayTextColor;
    _driverL.backgroundColor = [UIColor colorWithRed:247.0 / 255 green:247.0 / 255 blue:247.0 / 255 alpha:1];
    [self addSubview:_driverL];
    
    _speedL = [[UILabel alloc] init];
    _speedL.font      = [UIFont systemFontOfSize:15];
    _speedL.textColor = kROLightFrayTextColor;
    _speedL.backgroundColor = [UIColor colorWithRed:247.0 / 255 green:247.0 / 255 blue:247.0 / 255 alpha:1];
    [self addSubview:_speedL];
    
    _userNameL = [[UILabel alloc] init];
    _userNameL.font      = [UIFont systemFontOfSize:15];
    _userNameL.textColor = kROLightFrayTextColor;
    _userNameL.backgroundColor = [UIColor colorWithRed:247.0 / 255 green:247.0 / 255 blue:247.0 / 255 alpha:1];
    [self addSubview:_userNameL];
    
    _departureL = [[UILabel alloc] init];
    _departureL.font      = [UIFont systemFontOfSize:15];
    _departureL.textColor = kROLightFrayTextColor;
    
    _departureL.backgroundColor = [UIColor colorWithRed:247.0 / 255 green:247.0 / 255 blue:247.0 / 255 alpha:1];
    [self addSubview:_departureL];
    
    _destinationL = [[UILabel alloc] init];
    _destinationL.font      = [UIFont systemFontOfSize:15];
    _destinationL.textColor = kROLightFrayTextColor;
    _destinationL.backgroundColor = [UIColor colorWithRed:247.0 / 255 green:247.0 / 255 blue:247.0 / 255 alpha:1];
    [self addSubview:_destinationL];
    
    _returnTimeL = [[UILabel alloc] init];
    _returnTimeL.font      = [UIFont systemFontOfSize:15];
    _returnTimeL.textColor = kROLightFrayTextColor;
    _returnTimeL.text      = @"返程时间";
    _returnTimeL.backgroundColor = [UIColor colorWithRed:247.0 / 255 green:247.0 / 255 blue:247.0 / 255 alpha:1];
    [self addSubview:_returnTimeL];
    
    // 历史轨迹查询
    _trackL = [[UILabel alloc] init];
    _trackL.font      = [UIFont fontWithName:@"HelveticaNeue" size:17];
    _trackL.text      = @"   历史轨迹查询";
    [self addSubview:_trackL];
    
    _historyBtn = [[UIButton alloc] init];
    [_historyBtn setTitle:@"历史记录" forState:UIControlStateNormal];
    [_historyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_historyBtn setBackgroundColor:[UIColor colorWithRed:12.0 / 255 green:84.0 / 255 blue:118.0 / 255 alpha:1]];
    [self addSubview:_historyBtn];
    
    _beginTimeBtn     = [[UIButton alloc] init];
    _beginTimeBtn.layer.cornerRadius = 2;
    _beginTimeBtn.clipsToBounds      = YES;
    [self addSubview:_beginTimeBtn];
    
    _beginTimeL                     = [[UILabel alloc] init];
    _beginTimeL.backgroundColor     = [UIColor clearColor];
    _beginTimeL.font                = [UIFont fontWithName:@"HelveticaNeue" size:15];
    _beginTimeL.text                = @"开始时间";
    _beginTimeL.textColor           = [UIColor whiteColor];
    _beginTimeL.layer.cornerRadius  = 5;
    _beginTimeL.layer.masksToBounds = YES;
    _beginTimeL.backgroundColor     = [UIColor colorWithRed:57.0 / 255 green:169.0 / 255 blue:215.0 / 255 alpha:1];
    _beginTimeL.textAlignment       = NSTextAlignmentCenter;
    [self addSubview:_beginTimeL];
    
    _showBeginT                     = [[UILabel alloc] init];
    _showBeginT.text                = @"请选择时间";
    _showBeginT.font                = [UIFont systemFontOfSize:15];
    _showBeginT.textColor           = [UIColor whiteColor];
    _showBeginT.backgroundColor     = [UIColor colorWithRed:57.0 / 255 green:169.0 / 255 blue:215.0 / 255 alpha:1];
    _showBeginT.layer.cornerRadius  = 4;
    _showBeginT.layer.masksToBounds = YES;
    _showBeginT.textAlignment       = NSTextAlignmentCenter;
    [self addSubview:_showBeginT];
    
    _endTimeBtn                    = [[UIButton alloc] init];
    _endTimeBtn.backgroundColor    = [UIColor clearColor];
    _endTimeBtn.layer.cornerRadius = 4;
    _endTimeBtn.clipsToBounds      = YES;
    [self addSubview:_endTimeBtn];
    
    _endTimeL                    = [[UILabel alloc] init];
    _endTimeL.text               = @"结束时间";
    _endTimeL.textColor          = [UIColor whiteColor];
    _endTimeL.layer.cornerRadius = 4;
    _endTimeL.clipsToBounds      = YES;
    _endTimeL.backgroundColor    = [UIColor colorWithRed:57.0 / 255 green:169.0 / 255 blue:215.0 / 255 alpha:1];
    _endTimeL.font               = [UIFont fontWithName:@"HelveticaNeue" size:15];
    _endTimeL.textAlignment      = NSTextAlignmentCenter;
    [self addSubview:_endTimeL];
    
    _showEndT                    = [[UILabel alloc] init];
    _showEndT.text               = @"请选择时间";
    _showEndT.layer.cornerRadius = 4;
    _showEndT.clipsToBounds      = YES;
    _showEndT.textColor          = [UIColor whiteColor];
    _showEndT.font               = [UIFont systemFontOfSize:15];
    _showEndT.textAlignment      = NSTextAlignmentCenter;
    _showEndT.backgroundColor    = [UIColor colorWithRed:57.0 / 255 green:169.0 / 255 blue:215.0 / 255 alpha:1];
    [self addSubview:_showEndT];
    
    
    _inquiryBtn = [[UIButton alloc] init];
    [_inquiryBtn setTitle:@"查询" forState:UIControlStateNormal];
    [_inquiryBtn setBackgroundColor:[UIColor colorWithRed:12.0 / 255 green:84.0 / 255 blue:118.0 / 255 alpha:1]];
    _inquiryBtn.layer.cornerRadius = 2;
    _inquiryBtn.clipsToBounds      = YES;
    [self addSubview:_inquiryBtn];
    
    //车载视频截图
    _videoL = [[UILabel alloc] init];
    _videoL.font      = [UIFont fontWithName:@"HelveticaNeue" size:17];
    _videoL.textColor = [UIColor blackColor];
    _videoL.text      = @"   车载视频截图";
    [self addSubview:_videoL];
}

- (void) layoutUI {
    __weak __typeof(self)weakSelf = self;
    // 地图
    [_mapBackView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.mas_top);
        make.left.mas_equalTo(weakSelf.mas_left);
        make.right.mas_equalTo(weakSelf.mas_right);
        make.height.mas_equalTo(200);
    }];
    
    [_mapView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.mapBackView.mas_top);
        make.left.mas_equalTo(weakSelf.mapBackView.mas_left);
        make.right.mas_equalTo(weakSelf.mapBackView.mas_right);
        make.height.mas_equalTo(200);
    }];
    
    [_enlargeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.mapBackView.mas_top).with.offset(10);
        make.right.mas_equalTo(weakSelf.mapBackView.mas_right).with.offset(-15);
        make.height.mas_equalTo(SecondMapBtnWH);
        make.width.mas_equalTo(SecondMapBtnWH);
    }];
    
    [_trafficBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.enlargeBtn.mas_bottom).with.offset(5);
        make.right.mas_equalTo(weakSelf.enlargeBtn.mas_right);
        make.height.mas_equalTo(SecondMapBtnWH);
        make.width.mas_equalTo(SecondMapBtnWH);
    }];
    
    //用车信息
    [_carMessageL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.mapBackView.mas_bottom);
        make.height.mas_equalTo(40);
        make.left.mas_equalTo(weakSelf.mas_left);
        make.right.mas_equalTo(weakSelf.mas_right);
    }];
    
    [_driverL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.carMessageL.mas_bottom);
        make.height.mas_equalTo(35);
        make.left.mas_equalTo(weakSelf.mas_left);
        make.right.mas_equalTo(weakSelf.mas_centerX);
    }];
    
    [_speedL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.carMessageL.mas_bottom);
        make.height.mas_equalTo(35);
        make.left.mas_equalTo(weakSelf.mas_centerX);
        make.right.mas_equalTo(weakSelf.mas_right);
    }];
    
    [_userNameL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.driverL.mas_bottom).with.offset(2);
        make.height.mas_equalTo(35);
        make.left.mas_equalTo(weakSelf.mas_left);
        make.right.mas_equalTo(weakSelf.mas_right);
    }];
    
    [_departureL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.userNameL.mas_bottom).with.offset(2);
        make.height.mas_equalTo(35);
        make.left.mas_equalTo(weakSelf.mas_left);
        make.right.mas_equalTo(weakSelf.mas_right);
    }];
    
    [_destinationL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.departureL.mas_bottom).with.offset(2);
        make.height.mas_equalTo(35);
        make.left.mas_equalTo(weakSelf.mas_left);
        make.right.mas_equalTo(weakSelf.mas_right);
    }];
    
    [_returnTimeL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.destinationL.mas_bottom).with.offset(2);
        make.height.mas_equalTo(35);
        make.left.mas_equalTo(weakSelf.mas_left);
        make.right.mas_equalTo(weakSelf.mas_right);
    }];
    
    // 历史轨迹查询
    //    [_trackBackV mas_makeConstraints:^(MASConstraintMaker *make) {
    //        make.top.mas_equalTo(weakSelf.returnTimeL.mas_bottom);
    //        make.left.mas_equalTo(weakSelf.mas_left);
    //        make.right.mas_equalTo(weakSelf.mas_right);
    //    }];
    
    [_trackL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.returnTimeL.mas_bottom).with.offset(2);
        make.height.mas_equalTo(40);
        make.left.mas_equalTo(weakSelf.mas_left);
        make.right.mas_equalTo(weakSelf.mas_right);
    }];
    
    [_historyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.trackL.mas_centerY);
        make.height.mas_equalTo(30);
        make.width.mas_greaterThanOrEqualTo(100);
        make.right.mas_equalTo(weakSelf.mas_right).with.offset(-10);
    }];
    
    [_beginTimeBtn mas_makeConstraints:^(MASConstraintMaker *make) { //选择
        make.top.mas_equalTo(weakSelf.trackL.mas_bottom).with.offset(15);
        make.height.mas_equalTo(45);
        make.left.mas_equalTo(weakSelf.mas_left).with.offset(10);
        make.right.mas_equalTo(weakSelf.mas_centerX).with.offset(-10);
    }];
    
    [_beginTimeL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.trackL.mas_bottom).with.offset(15);
        make.height.mas_equalTo(30);
        make.left.mas_equalTo(weakSelf.mas_left).with.offset(10);
        make.right.mas_equalTo(weakSelf.mas_centerX).with.offset(-10);
    }];
    
    [_showBeginT mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.beginTimeL.mas_bottom).with.offset(-6);
        make.height.mas_equalTo(20);
        make.left.mas_equalTo(weakSelf.mas_left).with.offset(10);
        make.right.mas_equalTo(weakSelf.mas_centerX).with.offset(-10);
    }];
    
    [_endTimeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.trackL.mas_bottom).with.offset(15);
        make.height.mas_equalTo(45);
        make.left.mas_equalTo(weakSelf.mas_centerX).with.offset(10);
        make.right.mas_equalTo(weakSelf.mas_right).with.offset(-10);
    }];
    
    [_endTimeL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.trackL.mas_bottom).with.offset(15);
        make.height.mas_equalTo(30);
        make.left.mas_equalTo(weakSelf.mas_centerX).with.offset(10);
        make.right.mas_equalTo(weakSelf.mas_right).with.offset(-10);;
    }];
    
    [_showEndT mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.endTimeL.mas_bottom).with.offset(-6);
        make.height.mas_equalTo(20);
        make.left.mas_equalTo(weakSelf.mas_centerX).with.offset(10);
        make.right.mas_equalTo(weakSelf.mas_right).with.offset(-10);
    }];
    
    [_inquiryBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.endTimeBtn.mas_bottom).with.offset(15);
        make.height.mas_equalTo(35);
        make.left.mas_equalTo(weakSelf.mas_left).with.offset(10);
        make.right.mas_equalTo(weakSelf.mas_right).with.offset(-10);
    }];
    
    
    
    //车载视屏截图
    [_videoL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.inquiryBtn.mas_bottom).with.offset(15);
        make.height.mas_equalTo(40);
        make.left.mas_equalTo(weakSelf.mas_left);
        make.right.mas_equalTo(weakSelf.mas_right);
    }];
    
}

//-(void)setOneInVcModel:(InVehicleModel *)oneInVcModel {
//    _oneInVcModel = oneInVcModel;
//}

//- (void) getType:(CarManagerModel *)model {
//    switch (model.VehicleType) {
//        case 1:
//            _vcType =
//            break;
//            
//        default:
//            break;
//    }
//}

- (void)setIntData:(IntVclDetailInfoModel *)intModel carData:(CarManagerModel *)carMoel andListData:(InVehicleModel *)listModel{
    _intVcModel = intModel;
    _carModel   = carMoel ;
    _listModel  = listModel;
    
//    [self loadAnnotationViewLatitude:[intModel.Latitude floatValue] AndLongitude:[intModel.Longitude floatValue]];
//    _vcType = _carModel.VehicleType;
    // 标注地图
    if ([intModel.Latitude integerValue] != 0 && [intModel.Longitude integerValue] != 0 ) {
        [self loadAnnotationViewLatitude:[intModel.Latitude floatValue] AndLongitude:[intModel.Longitude floatValue]];
    }
//    else if (_carModel){
//        [self loadAnnotationViewLatitude:carMoel.Latitude AndLongitude:carMoel.Longitude];
//        _vcType = carMoel.VehicleType;
//    }else if (listModel.latitude != 0 && listModel.longitude != 0){
//        [self loadAnnotationViewLatitude:listModel.latitude  AndLongitude:listModel.longitude];
//        _vcType = listModel.VehicleType;
//    }
    else { //  // 2.189339--1.353861--8.815084--24.343250--113.323592
        [self loadAnnotationViewLatitude:24.343250 AndLongitude:113.323592];
    }
    if (_carModel) {
         _vcType = _carModel.VehicleType;
    }
    if (_listModel) {
         _vcType = _listModel.VehicleType;
    }
    
    
    //司机
    if (intModel.DrivedRecordInfo.Driver) {
        _driverL.text = [NSString stringWithFormat:@"   司 机 :%@",intModel.DrivedRecordInfo.Driver];
    }else {
        _driverL.text = @"   司 机 :";
    }
    // 车速
////    if (carMoel.OD_Rate) {
////        _speedL.text = [NSString stringWithFormat:@"   车 速 :%@km/h",carMoel.OD_Rate];
////    }else if (intModel.OD_Rate ) {
//        _speedL.text = [NSString stringWithFormat:@"   车 速 :%@km/h",intModel.OD_Rate];
////    }else if (_listModel.OD_Rate) {
////        _speedL.text = [NSString stringWithFormat:@"   车 速 :%@km/h",listModel.OD_Rate];
////    }
//    else {
//        _speedL.text = @"   车速:";
//    }
        if (intModel.OD_Rate ) {
            _speedL.text = [NSString stringWithFormat:@"   车 速 :%@km/h",intModel.OD_Rate];
        } else {
            _speedL.text = @"   车速:";
     }
    
    
    // 用车人 VclUserName
    IntVclUserInfoModel *model = [intModel.DrivedRecordInfo.IntVclUserInfoList lastObject];
    if (model.VclUserName) {
        _userNameL.text = [NSString stringWithFormat:@"   用车人 :%@",model.VclUserName];
    }else {
        _userNameL.text = @"   用车人 :";
    }
    // 出发地
    if (intModel.DrivedRecordInfo.Origin) {
        _departureL.text = [NSString stringWithFormat:@"   出发地 :%@",intModel.DrivedRecordInfo.Origin];
    }else {
        _departureL.text = @"   出发地 :";
    }
    // 目的地
    if (intModel.DrivedRecordInfo.Destination) {
        _destinationL.text = [NSString stringWithFormat:@"   目的地 :%@",intModel.DrivedRecordInfo.Destination];
    }else {
        _destinationL.text = @"   目的地 :";
    }
    // 返程时间
    if (intModel.DrivedRecordInfo.PlanReturnTime) {
        _returnTimeL.text = [NSString stringWithFormat:@"   返程时间:%@",intModel.DrivedRecordInfo.PlanReturnTime];
    }else {
        _returnTimeL.text = @"   返程时间:";
    }
}
#pragma mark - 添加地图标注
- (void) loadAnnotationViewLatitude:(CGFloat )la AndLongitude:(CGFloat )lo {
    ROPointAnnotation *roAnnotation = [[ROPointAnnotation alloc] init];
    CLLocationCoordinate2D ret = CLLocationCoordinate2DMake(la, lo);
    roAnnotation.coordinate = ret;
    _intVcModel.Latitude = [NSString stringWithFormat:@"%f",ret.latitude];
    _intVcModel.Longitude = [NSString stringWithFormat:@"%f",ret.longitude];
    [_annotationsArray addObject:roAnnotation];
    [_mapView addAnnotations:_annotationsArray];
    [_mapView showAnnotations:_annotationsArray animated:NO];
}

#pragma mark -地图代理
//设置地图大头针
- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id <MAAnnotation>)annotation {
    if ([annotation isKindOfClass:[MAPointAnnotation class]])
    {
        static NSString *pointReuseIndentifier = @"pointReuseIndentifier";
        CustomAnnotationView *annotationView = (CustomAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:pointReuseIndentifier];
        if (annotationView == nil) {
            annotationView = [[CustomAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pointReuseIndentifier];
        }
           //设置气泡可以弹出，默认为NO
        annotationView.canShowCallout= NO;
        
        switch (self.vcType ) {
            case 1:{
                
                if ([_intVcModel.OD_Rate integerValue] == 0 && [_carModel.OD_Rate integerValue] == 0) {
                    annotationView.image = [UIImage imageNamed:@"road_admin_stop"];
                }else {
                annotationView.image = [UIImage imageNamed:@"road_admin_move"];//路政
                }
            }
                break;
            case 2:{
                if ([_intVcModel.OD_Rate integerValue] == 0 && [_carModel.OD_Rate integerValue] == 0 ) {
                    annotationView.image = [UIImage imageNamed:@"save_stop"];//救援
                }else {
                annotationView.image = [UIImage imageNamed:@"save_move"];//救援
                }
            }
                break;
            case 3:
                if ([_intVcModel.OD_Rate integerValue] == 0 && [_carModel.OD_Rate integerValue] == 0 ) {
                    annotationView.image = [UIImage imageNamed:@"conservation_stop"];//养护停
                }else {
                    annotationView.image = [UIImage imageNamed:@"conservation_move"];//养护
                }
                
                break;
            case 4:
                
                break;
            default:{
                if ([_intVcModel.OD_Rate integerValue] == 0 && [_carModel.OD_Rate integerValue] == 0 ) {
                    annotationView.image = [UIImage imageNamed:@"administrative_stop"];//行政
                }else {
                annotationView.image = [UIImage imageNamed:@"administrative_move"];//行政
                }
            }
                
                break;
        }
        return annotationView;
    }
    return nil;
}

- (void)mapView:(MAMapView *)mapView didSelectAnnotationView:(MAAnnotationView *)view {
    CustomAnnotationView *customView = (CustomAnnotationView *)view;
    customView.selected              = NO;
}

@end
